import fetch from "node-fetch";

//异步编程发送get请求
// const url = "http://ajax-base-api-t.itheima.net/api/getbooks";
// const getData = async () => {
//   try {
//     const res = await fetch(url);
//     const json = await res.json();
//     console.log(json);
//   } catch (error) {
//     console.log(error);
//   }
// };

//拼接查询参数

const url = "http://ajax-base-api-t.itheima.net/api/getbooks?id=1";
const getData = async () => {
  try {
    const res = await fetch(url);
    const json = await res.json();
    console.log(json);
  } catch (error) {
    console.log(error);
  }
};

getData();
